package com.mice.loader
{
	import com.iyimo.event.LoadEvent;
	import com.iyimo.loader.MutilLoader;
	import com.iyimo.manager.SpriteManager;
	import com.iyimo.meta.MetaParser;
	
	public class MetaLoader extends MutilLoader{
		public function MetaLoader(){
			super();
		}
		
		override public function load(value:Array = null):void{
			super.load(value);
			loader.loadXml(source[_index]["url"]);
		}
		
		override protected function onComplete(e:LoadEvent):void{
			var data:String = String(e.data);
			
			var arr:Array = new Array();
			var lineArr:Array = data.split("\r\n");
			var pro:Array = (lineArr[1] as String).split("\t");
			
			for (var i:int = 2; i < lineArr.length; i++){
				var line:Array = (lineArr[i] as String).split("\t");
				var obj:Object = new Object();
				for (var j:int = 0;  j < line.length; j++){
					obj[pro[j]] = line[j];
				}
				arr.push(obj);
			}
			
			MetaParser.rawMeta[source[_index]["name"]] = arr;
			
			super.onComplete(e);
		}
		
		override protected function loadFinish():void{
			MetaParser.startParse();
			super.loadFinish();
		}
	}
}